<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>storage_ptr</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../index.html" title="Chapter 1. Boost.JSON">
<link rel="up" href="../ref.html" title="This Page Intentionally Left Blank 2/2">
<link rel="prev" href="boost__json__static_resource/release.html" title="static_resource::release">
<link rel="next" href="boost__json__storage_ptr/_dtor_storage_ptr.html" title="storage_ptr::~storage_ptr">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="boost__json__static_resource/release.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../ref.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="boost__json__storage_ptr/_dtor_storage_ptr.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="json.ref.boost__json__storage_ptr"></a><a class="link" href="boost__json__storage_ptr.html" title="storage_ptr">storage_ptr</a>
</h4></div></div></div>
<p>
        A smart pointer to a <a class="link" href="boost__json__memory_resource.html" title="memory_resource"><code class="computeroutput"><span class="identifier">memory_resource</span></code></a>.
      </p>
<h5>
<a name="json.ref.boost__json__storage_ptr.h0"></a>
        <span class="phrase"><a name="json.ref.boost__json__storage_ptr.synopsis"></a></span><a class="link" href="boost__json__storage_ptr.html#json.ref.boost__json__storage_ptr.synopsis">Synopsis</a>
      </h5>
<p>
        Defined in header <code class="literal">&lt;<a href="https://github.com/cppalliance/json/blob/master/include/boost/json/storage_ptr.hpp" target="_top">boost/json/storage_ptr.hpp</a>&gt;</code>
      </p>
<pre class="programlisting"><span class="keyword">class</span> <span class="identifier">storage_ptr</span>
</pre>
<h5>
<a name="json.ref.boost__json__storage_ptr.h1"></a>
        <span class="phrase"><a name="json.ref.boost__json__storage_ptr.member_functions"></a></span><a class="link" href="boost__json__storage_ptr.html#json.ref.boost__json__storage_ptr.member_functions">Member
        Functions</a>
      </h5>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
                <p>
                  Name
                </p>
              </th>
<th>
                <p>
                  Description
                </p>
              </th>
</tr></thead>
<tbody>
<tr>
<td>
                <p>
                  <span class="bold"><strong><a class="link" href="boost__json__storage_ptr/get.html" title="storage_ptr::get">get</a></strong></span>
                </p>
              </td>
<td>
                <p>
                  Return a pointer to the memory resource.
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  <span class="bold"><strong><a class="link" href="boost__json__storage_ptr/is_deallocate_trivial.html" title="storage_ptr::is_deallocate_trivial">is_deallocate_trivial</a></strong></span>
                </p>
              </td>
<td>
                <p>
                  Return <code class="computeroutput"><span class="keyword">true</span></code> if calling
                  <code class="computeroutput"><span class="identifier">deallocate</span></code> on the
                  memory resource has no effect.
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  <span class="bold"><strong><a class="link" href="boost__json__storage_ptr/is_not_shared_and_deallocate_is_trivial.html" title="storage_ptr::is_not_shared_and_deallocate_is_trivial">is_not_shared_and_deallocate_is_trivial</a></strong></span>
                </p>
              </td>
<td>
                <p>
                  Return <code class="computeroutput"><span class="keyword">true</span></code> if ownership
                  of the memory resource is not shared and deallocate is trivial.
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  <span class="bold"><strong><a class="link" href="boost__json__storage_ptr/is_shared.html" title="storage_ptr::is_shared">is_shared</a></strong></span>
                </p>
              </td>
<td>
                <p>
                  Return <code class="computeroutput"><span class="keyword">true</span></code> if ownership
                  of the memory resource is shared.
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  <span class="bold"><strong><a class="link" href="boost__json__storage_ptr/operator__star_.html" title="storage_ptr::operator *">operator
                  *</a></strong></span>
                </p>
              </td>
<td>
                <p>
                  Return a reference to the memory resource.
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  <span class="bold"><strong><a class="link" href="boost__json__storage_ptr/operator_arrow_.html" title="storage_ptr::operator-&gt;">operator-&gt;</a></strong></span>
                </p>
              </td>
<td>
                <p>
                  Return a pointer to the memory resource.
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  <span class="bold"><strong><a class="link" href="boost__json__storage_ptr/operator_eq_.html" title="storage_ptr::operator=">operator=</a></strong></span>
                </p>
              </td>
<td>
                <p>
                  Move assignment. <br> <span class="silver">—</span><br>
                  Copy assignment.
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  <span class="bold"><strong><a class="link" href="boost__json__storage_ptr/storage_ptr.html" title="storage_ptr::storage_ptr">storage_ptr</a> <span class="silver">[constructor]</span></strong></span>
                </p>
              </td>
<td>
                <p>
                  Constructor. <br> <span class="silver">—</span><br> Move
                  constructor. <br> <span class="silver">—</span><br> Copy
                  constructor.
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  <span class="bold"><strong><a class="link" href="boost__json__storage_ptr/_dtor_storage_ptr.html" title="storage_ptr::~storage_ptr">~storage_ptr</a> <span class="silver">[destructor]</span></strong></span>
                </p>
              </td>
<td>
                <p>
                  Destructor.
                </p>
              </td>
</tr>
</tbody>
</table></div>
<h5>
<a name="json.ref.boost__json__storage_ptr.h2"></a>
        <span class="phrase"><a name="json.ref.boost__json__storage_ptr.friends"></a></span><a class="link" href="boost__json__storage_ptr.html#json.ref.boost__json__storage_ptr.friends">Friends</a>
      </h5>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
                <p>
                  Name
                </p>
              </th>
<th>
                <p>
                  Description
                </p>
              </th>
</tr></thead>
<tbody><tr>
<td>
                <p>
                  <span class="bold"><strong><a class="link" href="boost__json__storage_ptr/make_shared_resource.html" title="storage_ptr::make_shared_resource">make_shared_resource</a></strong></span>
                </p>
              </td>
<td>
                <p>
                  Return shared ownership of a new, dynamically allocated memory
                  resource.
                </p>
              </td>
</tr></tbody>
</table></div>
<h5>
<a name="json.ref.boost__json__storage_ptr.h3"></a>
        <span class="phrase"><a name="json.ref.boost__json__storage_ptr.description"></a></span><a class="link" href="boost__json__storage_ptr.html#json.ref.boost__json__storage_ptr.description">Description</a>
      </h5>
<p>
        This container is used to hold a pointer to a memory resource. The pointed-to
        resource is always valid; default-constructed pointers use the default memory
        resource, which calls into the standard global system heap. Depending on
        the means of construction, the ownership will be either:
      </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
            Non-owning, when constructing from a raw pointer to <a class="link" href="boost__json__memory_resource.html" title="memory_resource"><code class="computeroutput"><span class="identifier">memory_resource</span></code></a> or from a <a class="link" href="boost__json__polymorphic_allocator.html" title="polymorphic_allocator"><code class="computeroutput"><span class="identifier">polymorphic_allocator</span></code></a>.
            In this case the caller is responsible for ensuring that the lifetime
            of the memory resource extends until there are no more calls to allocate
            or deallocate.
          </li>
<li class="listitem">
            Owning, when constructing using the function <a class="link" href="boost__json__storage_ptr/make_shared_resource.html" title="storage_ptr::make_shared_resource"><code class="computeroutput"><span class="identifier">make_shared_resource</span></code></a>. In this
            case ownership is shared; the lifetime of the memory resource extends
            until the last copy of the <a class="link" href="boost__json__storage_ptr.html" title="storage_ptr"><code class="computeroutput"><span class="identifier">storage_ptr</span></code></a> is destroyed.
          </li>
</ul></div>
<h5>
<a name="json.ref.boost__json__storage_ptr.h4"></a>
        <span class="phrase"><a name="json.ref.boost__json__storage_ptr.examples"></a></span><a class="link" href="boost__json__storage_ptr.html#json.ref.boost__json__storage_ptr.examples">Examples</a>
      </h5>
<p>
        These statements create a memory resource on the stack and construct a pointer
        from it without taking ownership:
      </p>
<pre class="programlisting"><span class="identifier">monotonic_resource</span> <span class="identifier">mr</span><span class="special">;</span>                  <span class="comment">// Create our memory resource on the stack</span>
<span class="identifier">storage_ptr</span> <span class="identifier">sp</span><span class="special">(</span> <span class="special">&amp;</span><span class="identifier">mr</span> <span class="special">);</span>                  <span class="comment">// Construct a non-owning pointer to the resource</span>
</pre>
<p>
        This function creates a pointer to a memory resource using shared ownership
        and returns it. The lifetime of the memory resource extends until the last
        copy of the pointer is destroyed:
      </p>
<pre class="programlisting"><span class="comment">// Create a counted memory resource and return it</span>
<span class="identifier">storage_ptr</span> <span class="identifier">make_storage</span><span class="special">()</span>
<span class="special">{</span>
    <span class="keyword">return</span> <span class="identifier">make_shared_resource</span><span class="special">&lt;</span> <span class="identifier">monotonic_resource</span> <span class="special">&gt;();</span>
<span class="special">}</span>
</pre>
<h5>
<a name="json.ref.boost__json__storage_ptr.h5"></a>
        <span class="phrase"><a name="json.ref.boost__json__storage_ptr.thread_safety"></a></span><a class="link" href="boost__json__storage_ptr.html#json.ref.boost__json__storage_ptr.thread_safety">Thread
        Safety</a>
      </h5>
<p>
        Instances of this type provide the default level of thread safety for all
        C++ objects. Specifically, it conforms to <a href="http://eel.is/c++draft/res.on.data.races" target="_top">16.4.6.10
        Data race avoidance</a>.
      </p>
<h5>
<a name="json.ref.boost__json__storage_ptr.h6"></a>
        <span class="phrase"><a name="json.ref.boost__json__storage_ptr.see_also"></a></span><a class="link" href="boost__json__storage_ptr.html#json.ref.boost__json__storage_ptr.see_also">See
        Also</a>
      </h5>
<p>
        <a class="link" href="boost__json__storage_ptr/make_shared_resource.html" title="storage_ptr::make_shared_resource"><code class="computeroutput"><span class="identifier">make_shared_resource</span></code></a>, <a class="link" href="boost__json__memory_resource.html" title="memory_resource"><code class="computeroutput"><span class="identifier">memory_resource</span></code></a>, <a class="link" href="boost__json__polymorphic_allocator.html" title="polymorphic_allocator"><code class="computeroutput"><span class="identifier">polymorphic_allocator</span></code></a>
      </p>
<p>
        Convenience header <code class="literal">&lt;<a href="https://github.com/cppalliance/json/blob/master/include/boost/json.hpp" target="_top">boost/json.hpp</a>&gt;</code>
      </p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2019, 2020 Vinnie Falco<br>Copyright © 2020 Krystian Stasiowski<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="boost__json__static_resource/release.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../ref.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="boost__json__storage_ptr/_dtor_storage_ptr.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
